package com.youbug.mall.order_oms.feign.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.youbug.common.to.OrderTo;
import com.youbug.common.vo.R;
import com.youbug.mall.order_oms.entity.OmsOrder;
import com.youbug.mall.order_oms.service.IOmsOrderService;
import com.youbug.mall.ware_wms.feign.IWareOrderFeignService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class WareOrderFeignServiceImpl implements IWareOrderFeignService {

    @Autowired
    private IOmsOrderService orderService;

    @Override
    public R<OrderTo> getOrderBySn(String orderSn) {

        OmsOrder omsOrder = orderService.getOne(new QueryWrapper<OmsOrder>().eq("order_sn", orderSn));
        if(omsOrder != null){
            OrderTo orderTo = new OrderTo();

            BeanUtils.copyProperties(omsOrder, orderTo);

            return R.ok(orderTo);
        }
            return R.ok();
    }
}
